/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.CustomerFieldManager;
/*    */ import com.newcrm.db.CustomerManager;
/*    */ import com.newcrm.db.UserManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.sql.SQLException;
/*    */ import java.util.List;
/*    */ import javax.servlet.RequestDispatcher;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ShowNewCompany extends AbstractAction
/*    */ {
/* 26 */   private static Logger logger = Logger.getLogger(ShowNewCompany.class
/* 27 */     .getName());
/*    */ 
/*    */   public ShowNewCompany(AbstractHttpServlet servlet)
/*    */   {
/* 30 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException
/*    */   {
/* 37 */     User user = super.getLoginUser(request);
/*    */ 
/* 39 */     UserManager userManager = new UserManager();
/* 40 */     String extValue = null;
/*    */     try {
/* 42 */       extValue = userManager.getExtInfoByType(user.userId, 
/* 43 */         2);
/*    */     } catch (DBException e1) {
/* 45 */       logger.warn("get user max customer num failed", e1);
/*    */     } catch (SQLException e1) {
/* 47 */       logger.warn("get user max customer num failed", e1);
/*    */     }
/* 49 */     int maxCompanyNum = Util.str2Int(extValue);
/* 50 */     if (maxCompanyNum > 0) {
/* 51 */       CustomerManager customerManager = new CustomerManager();
/* 52 */       int currentCompanyNum = customerManager
/* 53 */         .getUserCompanyNum(user.userId);
/* 54 */       if (maxCompanyNum <= currentCompanyNum) {
/* 55 */         request.setAttribute("currentNum", Integer.valueOf(currentCompanyNum));
/* 56 */         request.setAttribute("addNum", Integer.valueOf(1));
/* 57 */         request.setAttribute("maxNum", Integer.valueOf(maxCompanyNum));
/* 58 */         request.getRequestDispatcher("/company_new_error_overMax.jsp")
/* 59 */           .forward(request, response);
/* 60 */         return;
/*    */       }
/*    */ 
/*    */     }
/*    */ 
/* 65 */     String phone = request.getParameter("phone");
/*    */ 
/* 67 */     CustomerFieldManager manager = new CustomerFieldManager();
/* 68 */     List fields = manager.list(user.companyId, 
/* 69 */       1);
/* 70 */     request.setAttribute("fields", fields);
/* 71 */     request.setAttribute("phone", phone);
/* 72 */     request.getRequestDispatcher("/company_new.jsp").forward(request, 
/* 73 */       response);
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ShowNewCompany
 * JD-Core Version:    0.6.1
 */